<script lang="ts" setup>
import type { RecordListItem } from '@/types/api/record'
import { recordApi } from '@/request/api'
import { useHideLoading, useLoading, usePhoneMasking, useStringMasking, useToast } from '@/utils/index'
import { useHasPermission } from '@/utils/permission/permission'
import { to } from 'await-to-js'
import { defineEmits } from 'vue'

const props = defineProps<{
  item: RecordListItem
}>()
const emit = defineEmits(['update'])
async function onRecord() {
  useLoading(true)
  const [err, res] = await to(recordApi.ReviewRecord({ id: props.item.id }))
  if (err) {
    return
  }
  useToast('操作成功')
  emit('update')
  useHideLoading()
}
</script>

<template>
  <view
    class="btn-primary-theme h-60px w-60px flex items-center justify-center overflow-hidden rd-full text-35px text-#ffffff"
  >
    <!-- <ui-avatar :url="profile.userInfo ? profile.userInfo.orgInfo.appLog : undefined"></ui-avatar> -->
    <view>{{ item.name[0] }}</view>
  </view>
  <view class="ml-22px flex-1">
    <view class="flex items-center justify-between">
      <view class="flex items-center">
        <view class="text-35px">{{ item.name }}</view>
        <view class="ml-10px text-30px">{{
          useStringMasking(item.identNumber, 5, 4)
        }}</view>
      </view>
      <view v-if="item.status === 1" class="text ml-10px text-30px">
        通过
      </view>
      <view
        v-if="item.status === 2"
        class="ml-10px text-30px"
        style="color: #f53b0e"
      >
        拒绝
      </view>
      <view
        v-if="item.status === 0"
        class="ml-10px text-30px"
        style="color: #3d81f8"
      >
        待审
      </view>
    </view>
    <view class="flex items-center justify-between">
      <view>
        <view class="mt-20px flex">
          <view class="text-20px text-gray-400">{{
            usePhoneMasking(item.phone)
          }}</view>
        </view>
        <view class="mt-20px flex">
          <view class="text-20px text-gray-400">{{ item.createTime }}</view>
        </view></view>
      <view v-if="item.status === 0 && useHasPermission('/risk-review-record/query')" class="btn-primary-theme mt-30px rd-10px px-3 py-1 text-center text-23px text-white" @click.stop="onRecord">
        查询
      </view>
    </view>
  </view>
</template>

<style>

</style>
